// ----------------------------------------
// Filename: types.h
// Description: Declares new type definitions
// Author: Jon Maloney
//			Adopted from pmcl UTS embedded systems
// Date: 03-Apr-06

#ifndef TYPES_H
#define TYPES_H


#include "p24FJ64GA004.h"

// Signed types
typedef char INT8;
typedef int INT16;
typedef long INT32;

// Unsigned types
typedef unsigned char UINT8;
typedef unsigned int UINT16;
typedef unsigned long UINT32;

typedef UINT8 * ptr_8;
typedef UINT16 * ptr_16;
typedef UINT32 * ptr_32;
typedef void (*vFunc_ptr)();

typedef UINT16 kernelTickType;
typedef UINT16 kernelBASE_TYPE;
typedef UINT8 PRIORITY;

typedef enum
{
	eReady, 
	eWaiting,
	eRunning,
}eTASK_STATE;


#ifndef	NULL
#define	NULL	(0)
#endif	/* NULL */

#define PRIVILEGED_DATA __attribute__((section("privileged_data")))

// Unions to efficiently access hi and lo parts of integers and words
typedef union
{
  INT16 l;
  struct
  {
    INT8 Hi;
    INT8 Lo;
  } s;
} TINT16;

typedef union
{
  UINT16 l;
  struct
  {
    UINT8 Hi;
    UINT8 Lo;
  } s;
} TUINT16;

// Union to efficiently access hi and lo parts of a long integer
typedef union
{
  UINT32 l;
  struct
  {
    UINT16 Hi;
    UINT16 Lo;
  } s;
} TUINT32;

#define HI_BYTE s.Hi
#define LO_BYTE s.Lo

// Union to efficiently access individual bytes of a float
typedef union
{
  float d;
  struct
  {
    TUINT16 dHi;
    TUINT16 dLo;
  } dParts;
} TFloat;

#define HI_WORD dParts.dHi
#define LO_WORD dParts.dLo


// Boolean definition that includes type and value
typedef enum
{
  pdFALSE = 0,
  pdTRUE = 1
} BOOL;

typedef enum 
{
  eSuccess  = 0,
  eFail     = 1
}eSuccessful;

#define pdPASS pdTRUE
#define pdFAIL pdFALSE


#endif
